home *** CD-ROM | disk | FTP | other *** search
- Path: ratty.wolfe.net!usenet
- From: jrandom@wolfenet.com (Erik Seaberg)
- Newsgroups: comp.lang.c++
- Subject: Re: References & Pointers in Borland C++
- Date: Sat, 16 Mar 1996 12:27:38 GMT
- Organization: Wolfe Internet Access, L.L.C.
- Message-ID: <314aabda.3771725@news1.wolfe.net>
- References: <4i26j5$roe@dfw-ixnews3.ix.netcom.com> <4i5aem$9e7@coranto.ucs.mun.ca>
- NNTP-Posting-Host: sea-ts1-p37.wolfenet.com
- X-Newsreader: Forte Agent .99d/32.182
-
- On Wed, 13 Mar 1996 02:04:15 GMT, Steve Austin
- <saustin@terra.nlnet.nf.ca> wrote:
-
- > [...] given "int &ir = i", by itself "&ir" is *not* an int.
-
- I've heard this called "declaration mimics use," and it's unfortunate
- that references violate it, but since references are used
- transparently, there's no natural operator to hang off the identifier
- to declare a reference. Maybe the syntax should have been
- int *&ir;
- which is sort of a "use" that does the right thing to a reference,
- though it may overemphasize the theory that a reference is just a
- dereferenced pointer (it isn't, necessarily - a compiler has every
- right to use a register as the content of a reference, if it can do
- the bookkeeping to have everything modify it in-place).
-
- > Better I think to avoid this stylistic quirk and write "int* px"
- > meaning "px" is a pointer to an integer, and "int& ir = i", meaning
- > "ir" is a reference to an integer.
-
- Butting the operator symbol up with the type name seems to lead the
- unwary to think it's associated with it. I prefer
- int *a, b;
- to
- int* a, b;
- since they both declare one pointer and one int, but the unwary might
- think the latter declares two pointers. I know the usual answer is to
- declare only one object at a time, but I'm disturbed by the idea of
- avoiding legal syntax because I choose a style that makes it
- misleading.
-